import axios from 'axios'

const instance = axios.create({
    baseURL: 'http://119.23.228.238:3031/mock/58/group-3',
    timeout: 5000
})

//请求拦截
instance.interceptors.request.use((config) => {
    return config
},(error) => {
    return Promise.reject(error)
})

//响应拦截，一般进行错误处理
instance.interceptors.response.use((response) => {
    return response
}, (error) => {
    console.log('服务器响应错误',error);
    const _response = error.response
    switch(_response.status) {
        case 401:
            console.log('未登录')
            break;
    }
    return Promise.reject(error)
})
export default instance